home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 753 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.9 KB

  1. From: "Wil Evers" <wil@ittpub.nl>
  2. Message-ID: <0099F84782C14100.3D6072A5@ittpub.nl>
  3. X-Original-Date: Mon, 18 Mar 96 11:35:45 WET
  4. Path: in1.uu.net!bounce-back
  5. Date: 18 Mar 96 16:41:21 GMT
  6. Approved: fjh@cs.mu.oz.au
  7. Organization: -
  8. Newsgroups: comp.std.c++
  9. Subject: Static const data member initializers
  10. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  11.     iQBFAgUBMU2SROEDnX0m9pzZAQEuTAF/WeEylqrIY6g40JukFcDnQJ9oRlLBMmBl
  12.     XAxgv8Nr1O4IxB39iH+R0ufubQSxXuAK
  13.     =yi94
  14.  
  15. The DWP, section 9.5.2. [class.static.data], clause 4, says:
  16.  
  17. `If a static data member is of const integral or const enumeration type,
  18. its declaration in the class definition can specify a constant-initializer
  19. which shall be an integral constant expression (5.19). In that case, the
  20. member can appear in integral constant expressions within its scope. The
  21. member shall still be defined in a namespace scope and definition of the
  22. member in namespace scope shall not contain an initializer.'
  23.  
  24. Does anyone know the rationale behind requiring a definition of a static
  25. const data member that has been declared with an initializer? I mean, if I
  26. write:
  27.  
  28.         // header file
  29.  
  30.         class X { static const int bufSize = 42; };
  31.  
  32. then why should I be required to write
  33.  
  34.         // some translation unit
  35.  
  36.         const int X::bufSize;
  37.  
  38. It seems to me that interpreting bufSize's declaration-with-initializer in
  39. the class definition as a definition in class scope with internal linkage
  40. (analogous to an inline member function) would make more sense.
  41.  
  42. Thanks in advance,
  43.  
  44. - Wil
  45.  
  46. Wil Evers, <wil@ittpub.nl>
  47. ---
  48. [ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
  49. [ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
  50. [ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
  51. [ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
  52. [ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]
  53.